Part Number Hot Search : 
ZXM63N0 SA78CA CP210 2SB64 RTL8201 LQW15 11EWA 90858
Product Description
Full Text Search
 

To Download AN4035 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  september 2013 doc id 022669 rev 2 1/41 AN4035 application note flash programming through nexus/jtag 1 introduction the spc56x family of devices has internal flash used for code and data. the nexus debug interface can be used to program the flash using the jtag communication protocol through the jtag port. this allows programming of the internal flash by an external tool. this application note first addresses the jtag and nexus communication protocol. the jtag discussion includes the jtag signals, tap controller state machine, and the jtag controller. the explanation of nexus includes the on-chip emulation (once) module and the nexus read/write (r/w) access block. nexus/jtag flash programming supports the following products: spc563mxx spc564axx spc560dxx spc560bxx spc560cxx spc560pxx spc56elxx www.st.com
contents AN4035 2/41 doc id 022669 rev 2 contents 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 jtag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 jtag signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 tap controller state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 jtag controller (jtagc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.4.1 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.4.2 test mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.5 enabling debug of a censored device . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.5.1 censor_ctrl register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 on-chip emulation (once) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.1 enabling the once tap controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2 once register access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.3 once command register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.3.1 example of once register write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.3.2 example of once register read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.4 once status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.5 entering debug mode during reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.6 enabling external debug mode and other initialization . . . . . . . . . . . . . . . 21 3.7 cpu status and control scan chain register (cpuscr) . . . . . . . . . . . 21 3.7.1 instruction register (ir) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.7.2 control state register (ctl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.7.3 program counter register (pc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.7.4 write-back bus register (wbbrlow, wbbrhigh) . . . . . . . . . . . . . . . . . 24 3.7.5 machine state register (msr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.8 single step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.9 exit from debug mode to normal execution . . . . . . . . . . . . . . . . . . . . . . . 25 3.10 gpr access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.11 spr access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.12 once memory access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
AN4035 contents doc id 022669 rev 2 3/41 3.13 breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.13.1 software breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.13.2 instruction address hardware breakpoints . . . . . . . . . . . . . . . . . . . . . . . 27 4 nexus read/write access block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.1 nexus register access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.2 single memory write access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.3 burst block memory write access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.4 single memory read access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4.5 burst block memory read access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 5 system initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 5.1 internal sram initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 5.2 setting up the memory management unit . . . . . . . . . . . . . . . . . . . . . . . . 35 6 creating the flash programming tool . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.1 flash programming drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.2 tool requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.2.1 debug and driver initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.2.2 flashinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.2.3 setlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.2.4 flasherase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 6.2.5 flashprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 6.2.6 using other drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 6.3 functional division of the external tool . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
list of tables AN4035 4/41 doc id 022669 rev 2 list of tables table 1. jtag signal properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 table 2. jtag instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 table 3. once command register bit definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 table 4. e200z0 once register addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 5. rwcs field description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 table 6. read/write access status bit encoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 table 7. jtag data register (dr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 table 8. nexus register index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
AN4035 list of figures doc id 022669 rev 2 5/41 list of figures figure 1. tap controller finite state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 2. jtag controller block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 3. enabling jtag/nexus port access on a censored device . . . . . . . . . . . . . . . . . . . . . . . . . 11 figure 4. e200z once block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 5. steps for enabling the once tap controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 6. signal transitions for enabling the once tap controller . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 7. once command register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 8. dbcr0 register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 9. signal transitions for writing ocmd to select a write to dbcr0. . . . . . . . . . . . . . . . . . . . . 18 figure 10. signal transitions for writing dbcr0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 figure 11. signal transitions for writing ocmd to select a read from dbcr0 . . . . . . . . . . . . . . . . . . . 19 figure 12. signal transitions for reading dbcr0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 figure 13. once status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 14. signal transitions of reading the once status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 15. once control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 16. debug status register (dbsr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 figure 17. cpu status and control scan chain register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 figure 18. control state register (ctl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 figure 19. read/write access control/status register (rwcs). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 figure 20. read/write access data register (rwd). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 figure 21. read/write access address register (rwa) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
jtag AN4035 6/41 doc id 022669 rev 2 2 jtag jtag is a serial communication protocol developed by the joint test access group. originally developed for boundary scan, jtag is also used for communication with the nexus debug interface (ndi) on the spc560x devices. 2.1 jtag signals the jtag port of the spc56x devices consists of the tck, tdi, tdo, tms and jcomp pins. tdi, tdo, tms, and tck are compliant with the ieee 1149.1-2001 standard and are shared with the ndi through the test access port (tap) interface. see table 1 for signal properties. the jcomp pin assertion allows to put the jtagc in reset state. 2.2 tap controller state machine the tap controller state machine controls the jtag logic. the tap controller state machine is a 16-state finite state machine (fsm) as shown in figure 1 . the tck and tms signals control transition between states of the fsm. these two signals control whether an instruction register scan or data register scan is performed. both the tdi and tms inputs are sampled on the rising edge of tck while the tdo output changes on the falling edge of tck. the value shown next to each state of the state machine in figure 2 is the value of tms required on the rising edge of tck to transition to the connected state. five rising edges of tck with tms at logic 1 guarantee entry into the test logic reset state. table 1. jtag signal properties name i/o function tck i test clock tdi i test data in tdo o test data out tms i test mode select jcomp i jtag compliancy
AN4035 jtag doc id 022669 rev 2 7/41 figure 1. tap controller finite state machine test logic reset run-test/idl e select-dr-scan select-ir-scan capture-dr capture-ir sh ift-d r sh ift-ir exit1-d r exit1-ir pau se- dr pause-ir exit2-dr exit2-ir upd ate-dr upd ate-ir 1 0 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0
jtag AN4035 8/41 doc id 022669 rev 2 2.3 jtag controller (jtagc) the jtagc provides the means to test chip functionality and connectivity while remaining transparent to system logic when not in test mode. testing is performed via a boundary scan technique, as defined in the ieee 1149.1-2001 standard. in addition, instructions can be executed in order to allow the test access port (tap) to be shared with other modules on the mcu. all data input to and output from the jtagc is communicated in serial format. a block diagram of the jtagc is shown in figure 3 . figure 2. jtag controller block diagram 2.4 modes of operation access to the jtagc data registers is done by loading the instruction register with any of the jtagc instructions while the jtagc is enabled. instructions are shifted in via the select-ir-scan path and loaded in the update-ir state. at this point, all data register access is performed via the select-dr-scan path. the select-dr-scan path is used to read or write the register data by shifting in the data (lsb first) during the shift-dr state. when reading a register, the register value is loaded into the shifter during the capture-dr state. when writing a register, the value is loaded from tck tms tdi test access port (tap) tdo 32-bit device identification register boundary scan register . . controller 1-bit bypass register . test_ctrl register 5-bit tap instruction decoder 5-bit tap instruction register . . . . jcomp . censor_ctrl register
AN4035 jtag doc id 022669 rev 2 9/41 the shifter to the register during the update-dr state. when reading a register, there is no requirement to shift out the entire register contents. shifting can be terminated after fetching the required number of bits. 2.4.1 reset the jtagc is placed in reset when the tap controller state machine is in the test-logic- reset state. the test-logic-reset state is entered upon the assertion of the power-on reset signal, negation of jcomp, or through tap controller state machine transitions controlled by tms. asserting power-on reset or negating jcomp results in asynchronous entry into the reset state. while in reset, the following actions occur: the tap controller is forced into the test-logic-reset state, thereby disabling the test logic and allowing normal operation of the on-chip system logic to continue unhindered. the instruction register is loaded with the idcode instruction. in addition, execution of extest instruction results in assertion of the internal system reset. 2.4.2 test mode several test modes are supported, as well as a bypass mode and they are entered using the following instructions: extest sample sample/preload each instruction defines the set of data registers that can operate and interact with the on- chip system logic while the instruction is current. only one test data register path is enabled to shift data between tdi and tdo for each instruction. following the test modes available: 1. bypass mode when no test operation is required, the bypass instruction can be loaded to place the jtagc into bypass mode. while in bypass mode, the single-bit bypass shift register is used to provide a minimum-length serial path to shift data between tdi and tdo. 2. tap sharing mode there are three selectable auxiliary tap controllers that share the tap with the jtagc. selectable tap controllers include: - nexus port controller (npc) - on chip emulator (once) controller - tcu controller the instructions required to grant ownership of the tap to the auxiliary tap controllers are access_aux_tap_npc, access_aux_tap_once, access_aux_tap_tcu. instruction opcodes for each instruction are shown in tab le 2 . when the access instruction for an auxiliary tap is loaded, control of the jtag pins is transferred to the selected tap controller. any data input via tdi and tms is passed to the selected tap controller, and any tdo output from the selected tap controller is sent back to the jtagc to be output on the pins. the jtagc regains control of the jtag port during the update-dr state if the pause-dr state was entered. auxiliary tap controllers are held in run-test/idle wh ile they are inactive.
jtag AN4035 10/41 doc id 022669 rev 2 2.5 enabling debug of a censored device when a device is in a censored state, the debug port (jtag/nexus) is disabled and only jtag bsdl commands can be used. access to the nexus/jtag clients on a censored device requires inputting the proper password into the jtag censorship control register during reset. when the debug port is enabled on a censored device, it is enabled only until the next reset. figure 3 shows the logic that enables access to nexus clients in a censored device using the jtag port. table 2. jtag instructions instruction code[4:0] instruction summary idcode 00001 selects device identification register for shift sample/preload 00010 selects boundary scan register for shifting, sampling, and preloading without disturbing functional operation sample 00011 selects boundary scan register for shifting and sampling without disturbing functional operation extest 00100 selects boundary scan register while applying preloaded values to output pins and asserting functional reset access_aux_tap_tcu 10000 grants the tcu ownership of the tap access_aux_tap_once 10001 grants the platform ownership of the tap access_aux_tap_npc 10010 grants the nexus port controller (npc) ownership of the tap reserved 10010 - bypass 11111 selects bypass register for data operations factory debug reserved 00101 00110 01010 intended for factory debug only reserved all other codes decoded to select bypass register
AN4035 jtag doc id 022669 rev 2 11/41 figure 3. enabling jtag/nexus port access on a censored device the steps to enable the debug port on a censored device are as follows: 1. after the rstout pin has is negated, hold the device in system reset state using a debugger or other tool. 2. while the device is being held in system reset state shift the 64-bit password into the censor_ctrl register (via the jtag port using the jtag enable_censor_ctrl instruction. the jtag serial password is compared against the serial boot flash password from the flash shadow block. 3. if there is a match the nexus client tap controller enters normal operation mode and the disnex flag in the siu_ccr register is negated (for the spc56xb and spc56xp families the flag nxen in the sscm_status register is negated) indicating nexus is enabled. upon negation of reset the debug / calibration tool is able to access the device via nexus port and jtag. if the jtag serial password does not match the serial boot flash password or the serial boot flash password is an illegal password then the debug / calibration tool is not able to access the device. after the debug port is enabled, the tool can access the censored device and can erase and reprogram the shadow flash block in order to uncensor the device. compare 64-bit password jtag port controller censor_ctrl register nexus client tap controller debug/calibration tool access 64-bit password enable/disable censored flash array other nexus clients ?edma ? e200z3 processor . . .
jtag AN4035 12/41 doc id 022669 rev 2 note: if the shadow flash block is erased without reprogramming a new valid password before a reset, it contains an illegal password and the debug port is inaccessible. 4. subsequent resets clear the jtag censor password register and the nexus client tap controller holds in reset again. therefore, the tool must resend the jtag serial password, as described above, in order to enable the nexus client tap controller again. 2.5.1 censor_ctrl register the censor_ctrl register is an shift register path from tdi to tdo selected when the enable_censor_ctrl instruction is active. the censor_ctrl register transfers its value to a parallel hold register on the rising edge of tck when the tap controller state machine is in the update-dr state. the parallel hold register bits censor_ctrl correspond directly to the jtagc output control internal signals jtag_censor_ctrl. the jtag_censor_ctrl signals are used to control chip dependent censorship features. once the enable_censor_ctrl instruction is executed, jtag_censor_ctrl remains valid until a jtagc reset occurs.
AN4035 on-chip emulation (once) doc id 022669 rev 2 13/41 3 on-chip emulation (once) all of the spc56x devices possess a once module for debug control of the power architecture ? e200 core. the once logic provides nexus class 1 static debug capability including run-time control, register access, and memory access to all memory-mapped regions including on-chip peripherals, as well as providing access to the nexus2 & nexus3 configuration registers. the once module is controlled by the jtag signals through the once tap controller. figure 4. e200z once block diagram 3.1 enabling the once tap controller control of the once module is obtained through the once tap controller. to enable the once tap controller, the jtagc must have control of the tap and the access_aux_tap_once (0b10001) opcode must be loaded into the 5-bit jtagc instruction register with the jcomp signal set to a logic 1. the jtagc instruction register is loaded by scanning in the appropriate bits on the tdi pin, least significant bit (lsb) first, while in the shift-ir state of the tap controller state machine. the last bit is shifted in with tms set to a logical 1 causing transition from the shift-ir state to the exit1-ir state. table 3-1 shows the steps required to enable the once tap controller, assuming the tap controller state machine is initially in the run- tck e200z0_tms tdi test access port (tap) e200z0_tdo bypass register external data register . . controller tap instruction register . once mapped debug registers auxiliary data register . . . e200z0_trst (once ocmd) tdo mux control { from jtagc (to jtagc)
on-chip emulation (once) AN4035 14/41 doc id 022669 rev 2 test/idle state. the state machine is returned to the run-test/idle state when the write is complete. figure 6. signal transitions for enabling the once tap controller 3.2 once register access the once module provides several registers for static debug support. the once command register (ocmd) is a special register and acts as the ir for the tap controller state machine and is used to access other once resources. 3.3 once command register the once command register (ocmd) is a 10-bit shift register that receives its serial data from the tdi pin and acts as the ir register of the tap controller state machine. the ocmd is updated when the tap controller enters the update-ir state. it contains fields for figure 5. steps for enabling the once tap controller tck tick tms tdi resulting state 1 1 x select-dr-scan 2 1 x select-ir-scan 3 0 x capture-ir 40xshift-ir 501shift-ir 600shift-ir 700shift-ir 800shift-ir 911shift-ir 10 1 x update-ir 11 0 x run-test/idle
AN4035 on-chip emulation (once) doc id 022669 rev 2 15/41 controlling access to a resource, as well as controlling single step operations and exit from debug mode. figure 7 shows the register definition for the once command register. figure 7. once command register ta ble 3 provides bit definitions for the once command register. reset - 0b10_0000_0010 on assertion of jcomp, during power on reset, or while in the test logic reset state. 0123456789 r r/w go ex rs[0:6] w reset:0000011011 table 3. once command re gister bit definitions bit(s) name description 0r/w read/write command bit the r/w bit specifies the direction of data transfer. the table below describes the options defined by the r/w bit. 0 write the data associated with the command into the register specified by rs[0:6] 1 read the data contained in the register specified by rs[0:6] note: the r/w bit is ignored for read-only or write-only registers. in addition, it is ignored for all bypass operations. when performing writes, most registers are sampled in the capture-dr state into a 32-bit shift register, and subsequently shifted out on tdo during the first 32 clocks of shift-dr. 1go go command bit 0 inactive (no action taken) 1 execute instruction in ir if the go bit is set, the chip executes the instruction which resides in the ir register in the cpuscr. to execute the instruction, the processor leaves debug mode, executes the instruction, and if the ex bit is cleared, returns to debug mode immediately after executing the instruction. the processor goes on to normal operation if the ex bit is set, and no other debug request source is asserted. the go command is executed only if the operation is a read/write to cpuscr or a read/write to ?no register selected?. otherwise the go bit is ignored.the processor leaves debug mode after the tap controller update-dr state is entered. on a go+noexit operation, returning to debug mode is treated as a debug event, thus exceptions such as machine checks and interrupts may take priority and prevent execution of the intended instruction. debug firmware should mask these exceptions as appropriate. the osr[err] bit indicates such an occurrence.
on-chip emulation (once) AN4035 16/41 doc id 022669 rev 2 ta ble 4 shows the once register addresses. access to the registers cpuscr, dac1-2, dbcnt, dbcr0-3, dbsr, and iac1-4 require that the external debug mode bit, dbcr0[edm], be set to a logical 1. only the dbcr0[edm] is accessible in the dbcr0 register prior to that bit being set. setting dbcr0[edm] enables external debug mode and disables software updates to debug registers. the cpu should be placed in debug mode via the ocr[dr] bit prior to setting the dbcr0[edm] bit. 2ex 0 remain in debug mode 1 leave debug mode if the ex bit is set, the processor leaves debug mode and resume normal operation until another debug request is generated. the exit command is executed only if the go command is issued, and the operation is a read/write to cpuscr or a read/write to ?no register selected?. otherwise the ex bit is ignored. the processor leaves debug mode after the tap controller update-dr state is entered. note that if the dr bit in the once control register is set or remains set, or if a bit in the dbsr is set, or if a bit in the dbsr is set and dbcr0[edm]=1 (external debug mode is enabled), then the processor may return to debug mode without execution of an instruction, even though the ex bit was set. 3-9 rs register select the register select bits define which register is source (destination) for the read (write) operation. attempted writes to read-only registers are ignored. table 3. once command register bit definitions (continued) bit(s) name description table 4. e200z0 once register addressing rs[0:6] register selected 000 0000 reserved 000 0001 reserved 000 0010 jtag id (read-only) 000 0011-000 1111 reserved 001 0000 cpu scan register (cpuscr) 001 0001 no register selected (bypass) 001 0010 once control register (ocr) 001 0011-001 1111 reserved 010 0000 instruction address compare 1 (iac1) 010 0001 instruction address compare 2 (iac2) 010 0010 instruction address compare 3 (iac3) 010 0011 instruction address compare 4 (iac4) 010 0100 data address compare 1 (dac1) 010 0101 data address compare 2 (dac2) 010 0110 data value compare 1 (dvc1) 010 0111 data value compare 2 (dvc2)
AN4035 on-chip emulation (once) doc id 022669 rev 2 17/41 3.3.1 example of once register write once registers can be written by selecting the register using the rs[0:6] field and clearing the r/w bit in the once command register (ocmd). this requires a scan through the ir path of the tap controller state machine to write the ocmd and a scan through the dr path of the tap controller state machine to write the selected register. as mentioned above, the external debug mode bit, dbcr0[edm], must be set to a logical 1 to allow access to most of the once registers. therefore, writing the dcbr0 register to set the edm bit is used as an example of a writing a once register. figure 8 shows the register definition of dbcr0. figure 8. dbcr0 register the example of writing dbcr0 is divided into two parts: writing ocmd to select a write to dbcr0, and writing the value 0x80000000 to dbcr0. all data are scanned in least significant bit first. 010 1000 -010 1011 reserved 010 1100 debug counter register (dbcnt) 010 1101 debug pcfifo (pcfifo) (read-only) 010 1110 -010 1111 reserved 011 0000 debug status register (dbsr) 011 0001 debug control register 0 (dbcr0) 011 0010 debug control register 1 (dbcr1) 011 0011 debug control register 2 (dbcr2) 011 0100-101 1111 reserved 111 0000 -111 1001 general purpose register selects [0:9] 111 1010 cache debug access control register (cdacntl) 111 1011 cache debug access data register (cdadata) 111 1100 nexus3-access 111 1101 reserved 111 1110 enable_once 111 1111 bypass table 4. e200z0 once register addressing (continued) rs[0:6] register selected 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 r edm idm rst icmp brt irpt trap iac1 iac2 iac3 iac4 dac1 dac2 w reset00000 0 0 0 0 0 0 00000 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 r ret 0000 devt1 devt2 dcnt1 dcnt2 crpt cret 0000 ft w reset00000 0 0 0 0 0 0 00000
on-chip emulation (once) AN4035 18/41 doc id 022669 rev 2 figure 9 shows writing the value 0b00_0011_0001 to ocmd through the ir path to select a write to dbcr0 assuming the tap controller state machine is initially in the run- test/idle state. the state machine is returned to the run-test/idle state when the write is complete. figure 9. signal transitions for writing ocmd to select a write to dbcr0 figure 10 shows writing the value 0x80000000 to dbcr0 through the dr path to set the edm bit assuming the tap controller state machine is initially in the run-test/idle state. the state machine is returned to the run-test/idle state when the write is complete. figure 10. signal transi tions for writing dbcr0 3.3.2 example of once register read once registers can be read by selecting the register using the rs[0:6] field and setting the r/w bit in the once command register (ocmd). this requires a scan through the ir path of the tap controller state machine to write the ocmd and a scan through the dr path of the tap controller state machine to read the selected register. this read example reads dbcr0 after the edm bit is set. figure 11 shows writing the value 0b10_0011_0001 to ocmd through the ir path to select a read from dbcr0 assuming the tap controller state machine is initially in the run- test/idle state. the state machine is returned to the run-test/idle state when the write is complete. data starts on this clock edge    
AN4035 on-chip emulation (once) doc id 022669 rev 2 19/41 figure 11. signal transitions for writing ocmd to select a read from dbcr0 figure 12 shows reading the value 0x80000000 from dbcr0 through the dr path assuming the tap controller state machine is initially in the run-test/idle state. the state machine is returned to the run-test/idle state when the read is complete. figure 12. signal transitions for reading dbcr0 3.4 once status register the once status register (osr) is a special register in terms of how it is read. status information related to the state of the cpu is latched into the once status register when the once tap controller state machine enters the capture-ir state. the status information is shifted out serially through the shift-ir state on tdo. the osr is a 10-bit register like the ocmd. therefore, the status information can be read while writing ocmd. the osr is shown in figure 13 .
on-chip emulation (once) AN4035 20/41 doc id 022669 rev 2 figure 13. once status register figure 14 shows reading the once status register on tdo while writing the ocmd on tdi assuming the tap controller state machine is initially in the run-test/idle state. the state machine is returned to the run-test/idle state when the read is complete. the ocmd is written with the value 0b10_0001_0001 choosing a read of no register selected. the data read on tdo from the once status register is 0b10_0000_1001 showing that the osr[mclk] and osr[debug] status bits are set. all data is scanned in and out least significant bit first. figure 14. signal transitions of reading the once status register 3.5 entering debug mode during reset there are several different methods of entering debug mode. this section covers entering debug mode while the reset pin is asserted. entering debug mode while the reset pin is asserted is useful, because the debug session begins with the cpu in a known state. the once control register (ocr) controls entry into debug mode for this method. figure 15 shows the register definition for the ocr. figure 15. once control register the ocr[dr] bit is the cpu debug request control bit and requests the cpu to unconditionally enter debug mode. the ocr[wkup] bit is the wakeup request bit used to guarantee that the cpu clock is running. debug status and cpu clock activity can be determined by reading the debug and mclk bits in the once status register. after mclk err chkstop reset halt stop debug 0 1 0123456789 0dmdis0dwdidmdgde0 wk up fdb dr 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
AN4035 on-chip emulation (once) doc id 022669 rev 2 21/41 entering debug mode, the ocr[dr] bit should be cleared leaving the ocr[wkup] bit set. ocr[fdb] should also then be set to enable recognition of software breakpoints. the steps required for entering debug mode during reset assuming the once tap controller has been enabled are listed below: 1. assert reset. 2. set the ocr[dr] and ocr[wkup] bits. 3. de-assert reset. 4. verify debug mode via the debug bit in the once status register. 5. clear the ocr[dr] bit while leaving ocr[wkup] set and set ocr[fdb]. 3.6 enabling external debug m ode and other initialization before enabling external debug mode, the cpu should be placed into debug mode via the method outlined in the previous section. the external tool should then write the dbcr0[edm] bit to enable external debug mode. note that the first write to dbcr0 only affects the edm bit. all other bits in that register require dbcr0[edm] to be set prior to writing them. after enabling external debug mode, the dbsr status bits should be cleared by writing 0xffffffff to dbsr. the register definition of dbsr is shown in figure 16 . figure 16. debug status register (dbsr) 3.7 cpu status and control scan chain register (cpuscr) cpu information is accessible via the once module through a single scan chain register named the cpuscr. the cpuscr provides access to this cpu information and a mechanism for an external tool to set the cpu to a desired state before exiting debug mode. the cpuscr also provides the ability to access register and memory contents. figure 3-13 shows the cpuscr. once debug mode has been entered, it is required to scan in and update the cpuscr prior to exiting debug mode or single stepping. access to the cpuscr is controlled by the ocmd. 0123456789101112131415 r ide ude mrr icmp brt irpt trap iac1 iac2 iac3 iac4 dac 1r dac 1w dac 2r dac 2w w reset0001000000000000 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 rret0000 devt 1 dev t2 dcnt 1 dcnt 2 cirpt cret 0000 cnt 1rg w reset0000000000000000
on-chip emulation (once) AN4035 22/41 doc id 022669 rev 2 figure 17. cpu status and control scan chain register 3.7.1 instruction register (ir) after entering debug mode, the opcode of the next instruction to be executed is in the instruction register (ir). the value in the ir should be saved for later restoration if continuation of the normal instruction stream is desired. the external tool has the capability to put instructions directly into the instruction register (ir) via the cpuscr. these instructions can then be executed by the debug control block. by selecting appropriate instructions and single stepping them, the external tool can examine or change memory locations or cpu registers. wbbr low wbbr high msr pc ir ctl tdo tck tdi
AN4035 on-chip emulation (once) doc id 022669 rev 2 23/41 3.7.2 control state register (ctl) the control state register (ctl) stores the value of certain internal cpu state variables before debug mode is entered. figure 18 shows the ctl register. figure 18. control state register (ctl) the ?*? in the ctl register represents internal processor state bits that should be restored to the value they held when debug mode was entered prior to exiting debug mode. if a single step is executing an instruction that is in the normal instruction flow of the program that was running when debug mode was entered, these bits should be restored. if a single step is executing an instruction outside the normal instruction flow, these bits should be cleared to zero. the pcofst field indicates whether the value in the pc portion of the cpuscr must be adjusted prior to exiting debug mode. due to the pipelined nature of the cpu, the pc value must be backed-up under certain circumstances. the pcofst field specifies the value to be subtracted from the pc value when debug mode was entered. this pc value should be adjusted according to pcofst prior to exit from debug mode if continuation of the normal instruction stream is desired. in the event that pcofst is non-zero, the ir should be loaded with a nop instruction instead of the value in the ir when debug mode was entered. below are the possible values and meanings of the pcofst field: 0000?no correction required. 0001?subtract 0x04 from pc. 0010?subtract 0x08 from pc. 0011?subtract 0x0c from pc. 0100?subtract 0x10 from pc. 0101?subtract 0x14 from pc. all other encodings are reserved. after entering debug mode, the pcinv field overrides the pcofst field and indicates that values in the pc and ir are invalid. exiting debug mode with these pc and ir values have unpredictable results. no error condition exists. error condition exists. pc and ir are corrupt. the ffra control bit causes the contents of wbbr to be used as the ra (rs for logical and shift operations) operand value of the first instruction to be executed when exiting debug mode or the instruction to be single stepped. this allows the external tool to update cpu registers and memory. ra and rs are instruction syntax used to identify a source gpr. no action. contents of wbbr used as ra (rs for logical and shift operations) operand value. the irstat0-9 bits provide status information to the external tool. the irstat8 bit indicates that the instruction in the ir is a vle or non-vle instruction. for mpc5500 devices without * pcofst pcinv ffra irstat0 irstat1 irstat2 irstat3 irstat4 irstat5 irstat6 irstat7 irstat8 irstat9 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
on-chip emulation (once) AN4035 24/41 doc id 022669 rev 2 vle, bits irstat8 and irstat9 of the ctl do not exist. below is a description of the irstat8 bit. all other ctl bits are discussed as needed. ir contains a booke instruction. ir contains a powerpc vle instruction, aligned in the most significant portion of ir if 16-bit. 3.7.3 program counter register (pc) the pc stores the value of the program counter that was present when debug mode was entered. the pc value is affected by operations performed during debug mode and must be restored prior to exiting debug mode. it may be necessary to adjust the pc before exiting debug mode according the pcofst field in the ctl. if the external tool desires to redirect program flow to an arbitrary location, the pc and ir should be initialized corresponding to the first instruction to be executed. alternatively, the ir may be set to a nop instruction and the pc may be set to the location prior to the location at which it is desired to redirect flow. when debug mode is exited, the nop executes and then instruction fetch and execution begins at the location which it is desired to redirect flow. 3.7.4 write-back bus register (wbbr low , wbbr high ) wbbr is used as a means of passing operand information to/from the cpu from/to the external tool. whenever the external tool needs to read the contents of a cpu register or memory location, it can force the cpu to single step an instruction that brings that information to wbbr. to write the contents of a cpu register or memory location, the external tool can force the cpu to single step an instruction that uses the information in wbbr. for the purpose of this document, only wbbr low is used. wbbr high is used for spe instructions that generate 64-bit results or use 64-bit operands. such instructions are outside the scope of this document. 3.7.5 machine state register (msr) the msr is used to read/write the machine state register of the cpu. this register is affected by operations performed while in debug mode. if consistency of the machine state is desired, the msr should be saved when entering debug mode and restored prior to exiting debug mode. 3.8 single step single stepping of instructions is achieved by first placing the cpu in debug mode if the cpu is not already in debug mode. the next step is to write the appropriate information into the cpu scan chain register (cpuscr), followed by writing to ocmd to set the ocmd[go] bit and clear the ocmd[ex] bit with the ocmd[rs] field indicating either the cpuscr or no register selected. once debug mode has been entered, it is required that a scan in and update to the cpuscr must be performed prior to single stepping. for single step, the cpu returns to debug mode after executing a single instruction. the external tool should read the once status register (osr) to verify that the cpu has returned to debug mode without the osr. during single step, exception conditions can occur, if not masked, and may prevent the desired instruction from being executed. after stepping over the instruction, the core fetches the next instruction. the new program counter and instruction are loaded into the
AN4035 on-chip emulation (once) doc id 022669 rev 2 25/41 pc and ir portions of the cpuscr. care must be taken to insure that the next instruction fetch after the single step is to a valid memory location. for spc56x devices with vle, the ctl[irstat8] bit indicates that the instruction in the ir is a vle or non-vle instruction. the ctl[ffra], ctl[irstat8], and the ctl bits indicated by ?*? should be set as appropriate before single stepping. all other ctl bits should be set to zero. single stepping can be used during normal execution of the instruction flow or to force execution of a particular instruction by loading the desired instruction into the ir portion of the cpuscr. by forcing execution of particular instructions, single stepping can be used for memory and register access by the tool. 3.9 exit from debug mode to normal execution exiting debug mode and returning to normal execution is achieved by first clearing the ocr[dmdis] and ocr[dr] bits if not already clear while leaving the ocr[mclk] set. the next step is to write the appropriate information into the cpu scan chain register (cpuscr), followed by a write to ocmd to set the ocmd[go] bit and ocmd[ex] bit with the ocmd[rs] field indicating either the cpuscr or no register selected. once debug mode has been entered, it is required that a scan in and update to the cpuscr be performed prior to exiting debug mode. if continuation of the normal instruction stream is desired, the external tool is responsible for inspection of the ctl register value when debug mode was entered to determine if the pc is invalid or needs to be offset prior to exiting debug mode. also, the internal state bits indicated by ?*? in the ctl should be restored to their original value when debug mode was entered if continuation of the normal instruction stream is desired. the irstatus bits of the ctl should be set to zero with the exception of ctl[irstat8] on spc56x devices with vle. ctl[irstat8] indicates if the current instruction in the ir is a vle or non-vle instruction. to begin instruction execution from an arbitrary location, the pc should be set to the desired location for execution to begin minus 0x4. the ir should be set to a nop (ex: 0x60000000). then exit debug mode as mentioned above. the nop executes, then the core begins fetching instructions at the desired location for execution. 3.10 gpr access the once module provides the ability to read and write the general purpose registers (gpr) while in debug mode. reading a general purpose register is achieved by single stepping over an ori instruction. as an example, to read the lower 32 bits of gpr r1 , an ori r1 , r1 , 0 instruction is executed, and the result of the instruction is latched into wbbr low . the external tool can then read the contents of wbbr low by scanning out the cpuscr. writing a register is achieved by single stepping over an ori instruction with the ctl[ffra] bit set causing the wbbr low to be used as the source register for the instruction. as an example, to write the lower 32 bit of gpr r1 , an ori r1 , x , 0 is executed with the data to be written in wbbr low . the x in the instruction is replaced by the wbbr low register. 3.11 spr access the once module provides the ability to read and write the special purpose registers (spr) while in debug mode. reading a special purpose register is achieved by saving the value in a gpr, single stepping over a mfspr instruction which brings the spr value into both the
on-chip emulation (once) AN4035 26/41 doc id 022669 rev 2 saved gpr and wbbr low , and then restoring the gpr. as an example, to read spr 624, first save r31. then execute mfspr r31 , 624 . the value that was in spr 624 is now in wbbr low of the cpuscr and can be read by the external tool. finally r31 should be restored. to write an spr, single step over a mtspr instruction with the value to write to the spr in wbbr low and the ctl[ffra] bit set. for example, to write spr 624 with the value 0x10050000, single step over mtspr 624 , x with the value to write to spr 624 in wbbr low and ctl[ffra] set. the x in the instruction is replaced by wbbr low . dbcr0-3, dbsr, dbcnt, iac1-4, dac1-2 cannot be written by single stepping over mtspr like the other sprs while in external debug mode. they can however be written by the method detailed in section 3.2: once register access . 3.12 once memory access there are two ways to access memory mapped locations on the spc56x devices: one is through the once module, and the other is through the nexus r/w access block. the once module method requires that the cpu be in debug mode. the nexus r/w access block does not require that the cpu be in debug mode. the nexus r/w access block is also the faster method of accessing memory. this section covers access to memory mapped locations using the once method. the nexus r/w access block is covered in a following section. writing a memory location is achieved by first reading the contents of a gpr and saving that value, writing that gpr with the value to be written to memory, and single stepping over a stw , sth , or stb instruction with the address to write in wbbr low and the ctl[ffra] bit set. the gpr that was previously saved should be used as the rs field of the store instruction. after single stepping over the store instruction, the saved gpr value should then be restored. for example, to write the word 0xa5a5a5a5 to location 0x40000000, first save the value in a r31. then write the value 0xa5a5a5a5 to r31. the next step is to step over the instruction stw r31, 0(x) with 0x40000000 in wbbr low and the ctl[ffra] bit set. the x in the instruction is replaced by the wbbr low register. gpr r31 should then be restored to its saved value. reading a memory location is achieved by first reading the contents of a gpr and saving that value, then single stepping a lwz , lhz , or lbz with the address to be read in wbbr low and the ctl[ffra] bit set. the gpr that was previously saved should be used as the rd field of the load instruction. the value read from the memory location is then in both the wbbr low and the gpr whose value was previously saved. after single stepping the load instruction and getting the read data from wbbr low , the saved gpr value should then be restored. for example, to read a word from address location 0x40000000, first save the value in r31. then single step over the instruction lwz r31, 0(x) with 0x40000000 in wbbr low and the ctl[ffra] bit set. the x in the instruction is replaced by the wbbr low register. after the single step is complete, the data read from memory can be read by the external tool from wbbr low . gpr r31 should then be restored to its saved value. 3.13 breakpoints the once debug module provides the capability for both software and hardware breakpoints to be set at a particular address. as a reference, instruction address hardware breakpoints is also discussed in this section.
AN4035 on-chip emulation (once) doc id 022669 rev 2 27/41 3.13.1 software breakpoints recognition of software breakpoints by the once module are enabled by setting the ocr[fdb] bit along with the dbcr0[edm] bit. upon executing a bkpt pseudo-instruction, the cpu enters debug mode after the instruction following the bkpt pseudo-instruction has entered the instruction register. the bkpt pseudo-instruction is defined to be an all 0?s instruction opcode. 3.13.2 instruction address hardware breakp oints the once module provides the capability to set up to four instruction address hardware breakpoints. when an instruction address breakpoint is hit, the cpu enters debug mode prior to executing the instruction at that address location. when debug mode is entered due to a breakpoint, the cpuscr holds the address at which the breakpoint was set in the pc, and the ir contains the instruction at that address. to use an instruction address hardware breakpoint, these steps are required: 1. write the address at which a breakpoint is desired to one of the instruction address compare registers iac1, iac2, iac3, or iac4. 2. enable the instruction address compare debug event in the dbcr0 by setting the appropriate enable bit; dbcr0[iac1], dbcr0[iac2], dbcr0[iac3], or dbcr0[iac4]. 3. exit from debug mode to normal execution to execute the desired code. 4. poll the dbsr for the appropriate status bit to be set; dbsr[iac1], dbsr[iac2], dbsr[iac3], or dbsr[iac4]. 5. if the appropriate status bit in dbsr is set, verify entry into debug mode by reading the once status register. 6. clear the appropriate status bit by writing a 1 to that bit location in the dbsr; dbsr[iac1], dbsr[iac2], dbsr[iac3], or dbsr[iac4].
nexus read/write access block AN4035 28/41 doc id 022669 rev 2 4 nexus read/write access block the nexus module provided on the cores of the spc56x family of devices offers the capability for program trace, data trace, ownership trace, watchpoint messaging and trigger, and read/write (r/w) access to memory mapped regions. this section covers r/w access using the nexus r/w access block. the other features of the nexus module are out of the scope of this document and is not covered. unlike the once method of memory access, the nexus r/w access block provides the ability to read and write memory without having to stop code execution by entering debug mode. the nexus r/w access method provides faster memory access over the once method due to fewer jtag scans, and it doesn?t require loading and single stepping over any instructions. the nexus r/w access block is independent of the cpu. the r/w access block is controlled by three nexus registers. these registers are the read/write access control/status register (rwcs), read/write access data register (rwd), and read/write access address register (rwa). access to the nexus registers is covered in section 4.1 . rwcs is shown in figure 19 and figure 5 gives the field descriptions. figure 19. read/write access control/status register (rwcs) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 racrw sz map pr bst00000 w reset00000000000000000 nexus reg 0x7 1514131211109876543210 r cnt err dv w reset0000000000000000 nexus reg 0x7 table 5. rwcs field description bits name description 31 ac access control. 0 end access 1 start access 30 rw read/write select. 0 read access 1 write access
AN4035 nexus read/write access block doc id 022669 rev 2 29/41 ta ble 6 details the status bit encodings. rwd is shown in figure 20 . 29?27 sz [2:0] word size. 0008-bit (byte) 0016-bit (half-word) 01032-bit (word) 01164-bit (double-word - only in burst mode) 100?111 reserved (default to word) 26?24 map [2:0] map select. 000primary memory map 001-111 reserved 23?22 pr [1:0] read/write access priority. 00lowest access priority 01reserved (default to lowest priority) 10reserved (default to lowest priority) 11highest access priority 21 bst bst burst control. 0 module accesses are single bus cycle at a time. 1 module accesses are performed as burst operation. 20?16 ? reserved. 15?2 cnt [13:0] access control count. number of accesses of word size sz. 1 err read/write access error. see table 4-2. 0 dv read/write access data valid. see table 4-2. table 6. read/write access status bit encoding read action write action err dv read access has not completed write access completed without error 00 read access error has occurred write access error has occurred 10 read access completed without error write access has not completed 01 not allowed not allowed 1 1 table 5. rwcs field description (continued) bits name description
nexus read/write access block AN4035 30/41 doc id 022669 rev 2 figure 20. read/write access data register (rwd) rwa is shown in figure 21 . figure 21. read/write access address register (rwa) 4.1 nexus register access access to the nexus registers is enabled by loading the nexus3-access instruction (0b00_0111_1100) into the ocmd of the once. once the nexus3-access instruction has been loaded, reading/writing a nexus register requires two passes through the dr path the once tap controller state machine that are detailed below. 1. the first pass through the dr selects the nexus register to be accessed and whether the access is a read or a write. this is achieved by loading an 8-bit value lsb first into the jtag data register (dr). the format of this register is described in ta ble 7 . 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 r read/write data w reset0000000000000000 nexus reg 0xa 1514131211109876543210 r read/write data w reset0000000000000000 nexus reg 0xa 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 r read/write address w reset0000000000000000 nexus reg 0x9 1514131211109876543210 r read/write address w reset0000000000000000 nexus reg 0x9
AN4035 nexus read/write access block doc id 022669 rev 2 31/41 table 7. jtag data register (dr) 2. the second pass through the dr then shifts the data in or out depending on the type of access lsb first. a) during a read access, the data is latched from the nexus register when the tap controller state machine passes through the capture-dr state. the data from the nexus register can be read by the external tool by shifting the data out in the shift-dr state. the last bit is shifted out with tms set to 1, causing transition to the exit1-dr state. b) during a write access, the data is shifted in while in the shift-dr state. the last bit is shifted in with tms set to 1, causing transition to the exit1-dr state. the data is latched into the nexus register when the tap controller state machine passes through the update-dr state. table 8. nexus register index nexus register index value shown at bottom of register description read/write (r/w) 0 read 1 write (7-bits) (1-bit) nexus register index r/w reset value: 0x00
nexus read/write access block AN4035 32/41 doc id 022669 rev 2 4.2 single memory write access the steps to perform a single memory write access via the nexus r/w access block are: 1. initialize rwa with the address to be written using nexus register index 0x9. 2. initialize rwcs using nexus register index 0x7. a) access control (ac) = 0b1 (to indicate start access) b) map select (map) = 0b000 (primary memory map) c) access priority (pr) = 0b00 (lowest priority) d) read/write (rw) = 0b1 (write access) e) word size (sz) = 0b000 (8-bit) or 0b001 (16-bit) or 0b010 (32-bit) f) access count (cnt) = 0b00_0000_0000_0000 or 0b00_0000_0000_0001 (single access) g) burst control (bst) = 0b0 (burst disabled) 3. initialize rwd using nexus register index 0xa with the data to be written to the address in rwa. the endianess of the data needs to be right-justified little endian. - 8-bit value of 0xde to be written to memory: rwd = 0x000000de - 16-bit value of 0xdead to be written to memory: rwd = 0x0000adde - 32-bit value of 0xdeadbeef to be written to memory: rwd = 0xefbeadde 4. the nexus block then arbitrates for the system bus and transfer the data value from rwd to the memory mapped address in rwa. when the access has completed without error, then rwcs[err] = 0 and rwcs[dv] = 0. this indicates that the device is ready for the next access. nexus also asserts the rdy pin when the transaction has completed without error. the external tool can use this as an alternative to polling the rwcs status bits. 4.3 burst block memory write access the steps to perform a burst block memory write access via the nexus r/w access block are: 1. initialize rwa with the first address to be written using nexus register index 0x9. the address needs to be aligned on an 8-byte boundary. rwa[2:0] are ignored on a burst write. 2. initialize rwcs using nexus register index 0x7. a) access control (ac) = 0b1 (to indicate start access) b) map select (map) = 0b000 (primary memory map) c) access priority (pr) = 0b00 (lowest priority) d) read/write (rw) = 0b1 (write access) e) word size (sz) = 0b011 (64-bit) f) access count (cnt) = 0b00_0000_0000_0100 (four double-words)\ g) burst control (bst) = 0b1 (burst enabled) 3. write all 32 bytes of data to be burst to rwd using nexus register index 0xa, 32-bits at a time, starting with the first 32-bit word to be written to the address in rwa. this data
AN4035 nexus read/write access block doc id 022669 rev 2 33/41 is buffered internally by the burst data buffer. the endianess of the 32-bit data written to rwd needs to be little endian. -value of 0xdeadbeef to be written to memory: rwd = 0xefbeadde 4. the nexus block then arbitrates for the system bus and transfer the burst data from the burst data buffer to the memory starting at the address in rwa. when the access has completed without error, then rwcs[err] = 0 and rwcs[dv] = 0. this indicates that the device is ready for the next access. nexus also asserts the rdy pin when the transaction has completed without error. the external tool can use this as an alternative to polling the rwcs status bits. 4.4 single memory read access the steps to perform a single memory read access via the nexus r/w access block are: 1. initialize rwa with the address to be read using the register index 0x9. a) initialize rwcs using nexus register index 0x7. b) access control (ac) = 0b1 (to indicate start access) c) map select (map) = 0b000 (primary memory map) d) access priority (pr) = 0b00 (lowest priority) e) read/write (rw) = 0 (read access) f) word size (sz) = 0b000 (8-bit) or 0b001 (16-bit) or 0b010 (32-bit) g) access count (cnt) = 0b00_0000_0000_0000 or 0b00_0000_0000_0001 (single access) h) burst control (bst) = 0b0 (burst disabled) 2. the nexus block then arbitrates for the system bus and the read data is transferred to rwd from the memory mapped address in rwa. when the access has completed without error, then rwcs[err] = 0 and rwcs[dv] = 1. this indicates that the device is ready for the next access. nexus also asserts the rdy pin when the transaction has completed without error. the external tool can use this as an alternative to polling the rwcs status bits. 3. the data can then be read from the rwd register using nexus register index 0xa. the data in rwd are right-justified little endian. - 8-bit value of 0xde read from memory: rwd = 0x000000de - 16-bit value of 0xdead read from memory: rwd = 0x0000adde - 32-bit value of 0xdeadbeef read from memory: rwd = 0xefbeadde
nexus read/write access block AN4035 34/41 doc id 022669 rev 2 4.5 burst block memory read access the steps to perform a burst block memory read access via the nexus r/w access block are: 1. initialize rwa with the first address to be read using nexus register index 0x9. the address needs to be aligned on an 8-byte boundary. rwa[2:0] are ignored on a burst read. 2. initialize rwcs using nexus register index 0x7. - access control (ac) = 0b1 (to indicate start access) - map select (map) = 0b000 (primary memory map) - access priority (pr) = 0b00 (lowest priority) - read/write (rw) = 0b0 (read access) - word size (sz) = 0b011 (64-bit) - access count (cnt) = 0b00_0000_0000_0100 (four double-words)- - burst control (bst) = 0b1 (burst enabled) 3. the nexus block then arbitrates for the system bus and transfer the burst data from memory to the burst data buffer starting at the address in rwa. when the access has completed without error then rwcs[err] = 0 and rwcs[dv] = 1. see table 8 for details. this indicates that the device is ready for the next access. nexus also asserts the rdy pin when the transaction has completed without error. the external tool can use this as an alternative to polling the rwcs status bits. 4. read all 32 bytes of data from rwd using nexus register index 0xa, 32-bits at a time, starting with the first 32-bit word read from the address in rwa. the endianess of the 32-bit data read from rwd is little endian. - value of 0xdeadbeef read from memory: rwd = 0xefbeadde
AN4035 system initialization doc id 022669 rev 2 35/41 5 system initialization for flash programming, there is some system initialization that needs to be performed by the external tool. the initialization to perform is the sram initialization. 5.1 internal sram initialization the spc56x family of devices all contain internal sram that must be initialized after power- on-reset by 64-bit writes to the entire memory. this is necessary to initialize the error- correcting code (ecc) logic. the easiest way to do this with an external tool is to single step over a number of stmw (store multiple words) instructions with r0 as the rs field, the address to begin the writes in wbbr low , and ctl[ffra] set. this causes all 32 gprs to be written to memory beginning at the address in wbbr low using 64-bit writes. for example, the starting physical address of the internal sram is 0x40000000. stepping over stmw r0, 0(x) with the 0x40000000 in wbbr low causes all 32 gprs to be written to memory starting at address 0x40000000 using 64-bit writes. then 0x80 should be added to the address, written to wbbr low and stmw executed again. this should be done [size of internal sram] / [0x80] times to initialize the entire internal sram. 5.2 setting up the memory management unit the memory management unit (mmu) on the spc56x devices, that include this hardware implementation (for example spc560b devices don?t have this hardware implementation), provides memory translation from effective to real addresses. for the purpose of flash programming, it is easiest to setup the mmu such that the effective addresses are the same as the real addresses. for the cpu to access a memory mapped region, an mmu entry for that memory space must be configured. the external tool has the capability to setup mmu entries by writing the appropriate sprs and single stepping over the tlbwe instruction . for flash programming, the external tool should set up at least four mmu entries. the steps required to setup an mmu entry are: 1. setup mas0 (spr 624). 2. setup mas1 (spr 625). 3. setup mas2 (spr 626). 4. setup mas3 (spr 627). 5. execute tlbwe (0x7c0007a4).
creating the flash programming tool AN4035 36/41 doc id 022669 rev 2 6 creating the flash programming tool this section covers the flash drivers provided by stmicroelectronic ? , the tool requirements, and also suggests a functional division of the tool. 6.1 flash programming drivers stmicroelectronics provides a set of flash drivers called standard software driver for c90fl flash (ssd). these drivers are easy to use and well documented. the drivers come in a c-array format, s-record format, and library format. for external tools, the s-record format is the easiest to use. instructions on how to use the s-record format set of drivers is discussed in the next section. there are also examples of using the three driver formats provided with the installation of the ssd. 6.2 tool requirements the flash programming tool must perform several required tasks to program the flash on the spc56x devices. 6.2.1 debug and driver initialization the first requirement is to enter debug mode followed by the appropriate initialization. these steps must be performed every time a reset occurs or a new spc56x device is connected to the flash programming tool. the steps to do this are listed below. 1. ensure that the jtagc currently has control of the tap by going through the pause- dr state. see section 2.4.2: test mode for details. 2. enable the once tap controller by the method outlined in section 3.1: enabling the once tap controller . 3. enter debug mode during reset and enable recognition of software breakpoints as mentioned in section 3.5: entering debug mode during reset . 4. enable external debug mode and clear the debug status bits as mention in section 3.6: enabling external debug mode and other initialization . 5. setup the mmu as described in section 5.2: setting up the memory management unit . if it is necessary depending on the device used. 6. initialize the internal sram as mentioned in section 5.1: internal sram initialization . the next step is to load the s-record format flash driver set. the required drivers to load are flashinit, setlock, flashprogram, and flasherase. the other drivers are not required but could be loaded if features other than erasing and programming are desired. the s-record drivers all specify the start address to be 0x0 however the drivers are position independent. the tool should load each driver into internal sram at a desired location. the tool is responsible for knowing where these drivers are located in memory. space should also be reserved in the internal sram for variables needed for the driver set. for example, the ssd_config structure is used for all drivers. space must be allocated for this structure. space should also be allocated in internal sram for the stack and a buffer for the data to be programmed to flash. the drivers and variables can be written by the method described section 3.12: once memory access or the methods described in section 4: nexus read/write access block .
AN4035 creating the flash programming tool doc id 022669 rev 2 37/41 6.2.2 flashinit after the drivers are loaded into internal sram, operations on the flash can begin. the flashinit driver should be called first to initialize the flash. this function reads the flash configuration information from the flash control registers and initialize parameters in ssd configuration structure. ?flashinit()? must be called prior to any other flash operations. the steps required are outlined below. 1. setup the ssd_config structure as required. this is documented in the ssd user?s manual. the user should correctly initialize the fields c90flregbase , mainarraybase , shadowrowbase , shadowrowsize , pagesize , and bdmenable . the other fields are initialized when flashinit is executed. bdmenable should be set to 1 to cause debug mode to be entered via a software breakpoint when each driver completes execution. this is the easiest way for the external tool to determine when driver execution is complete. 2. setup r1 as the stack pointer by writing r1 using the method described in section 3.10: gpr access . 3. setup r3 to point to the ssd_config structure in internal sram. 4. set the pc to the beginning of flashinit minus 0x4 and load the ir with a nop (0x60000000). see section 3.7: cpu status and control scan chain register (cpuscr) for details. 5. exit debug mode and begin execution of the driver as described in section 3.9: exit from debug mode to normal execution . 6. poll the once status register to determine when debug mode has been re-entered. reading the once status register is described in section 3.4: once status register . 7. when debug mode has been entered, read the return value in r3. 6.2.3 setlock after the flash has been initialized using the flashinit function, the setlock function should be called as many times as required to unlock or lock the appropriate flash blocks. this function sets the block lock state for shadow/low/middle/high address space on the c90fl module to protect them from program/erase. the api provides password to enable block lock register writes when needed and write the block lock value to block lock register for the requested address space. for the low and mid blocks as well as the shadow block, the lock bits in both the primary and secondary lock registers must be set appropriately. it is recommended to lock the shadow block unless programming of the shadow block is absolutely necessary. erasing the shadow block without re-programming the censorship information prior to a reset causes the device to be censored with an invalid password and the flash of the device is not able to be uncensored. the steps to call the setlock driver are listed below.
creating the flash programming tool AN4035 38/41 doc id 022669 rev 2 1. setup r1 as the stack pointer. 2. setup r3 to point to the ssd_config structure in internal sram. 3. setup r4 with the lock indicator. 4. setup r5 with the lock state. 5. setup r6 with the correct password. 6. set the pc to the beginning of setlock minus 0x4 and load the ir with a nop (0x60000000). 7. exit debug mode and begin execution of the driver. 8. poll the once status register to determine when debug mode has been re-entered. 9. when debug mode has been entered, read the return value in r3. 6.2.4 flasherase when the appropriate blocks have been locked or unlocked, then an erase of the unlocked blocks can be performed. this function erases the enabled blocks in the main array or the shadow row. input arguments together with relevant flash module status is checked, and relevant error code returns if there is any error. the steps to call the flasherase driver are listed below. 1. setup r1 as the stack pointer. 2. setup r3 to point to the ssd_config structure in internal sram. 3. setup r4 to indicate either the main array or shadow block to be erased. erasing the shadow block without re-programming the censorship control information prior to a reset results in the device being censored. 4. setup r5 to select the low address array blocks to be erased. 5. setup r6 to select the mid address array blocks to be erased. 6. setup r7 to select the high address array blocks to be erased. 7. setup r8 with the pointer to the call back function. 8. set the pc to the beginning of flasherase minus 0x4 and load the ir with a nop (0x60000000). 9. exit debug mode and begin execution of the driver. 10. poll the once status register to determine when debug mode has been re-entered. 11. when debug mode has been entered, read the return value in r3. 6.2.5 flashprogram when flash blocks have been erased, they then can be programmed. to program the flash, the internal sram should first be written with the data to be programmed in flash. depending on the size of the data buffer in internal sram and the size of the data to be programmed to flash, the flashprogram driver may need to be called multiple times. this function programs the specified flash areas with the provided source data. input arguments together with relevant flash module status is checked, and relevant error code is returned if there is any error. the steps to call the flashprogram driver are listed below.
AN4035 creating the flash programming tool doc id 022669 rev 2 39/41 1. setup r1 as the stack pointer. 2. setup r3 to point to the ssd_config structure in internal sram. 3. setup r4 to point to the destination address to be programmed in flash. this address must be aligned on a double word boundary. 4. setup r5 to the size of the data in bytes to be programmed to flash. this size should be a multiple of 8 and the combination of the destination address and size should be entirely contained in the main array or shadow block. 5. setup r6 to point to the source buffer of data in internal sram to be programmed to flash. this address should be aligned on a word boundary. 6. setup r7 with the pointer to the call back function. 7. set the pc to the beginning of flashprogram minus 0x4 and load the ir with a nop (0x60000000). 8. exit debug mode and begin execution of the driver. 9. poll the once status register to determine when debug mode has been re-entered. 10. when debug mode has been entered, read the return value in r3. 6.2.6 using other drivers there are other useful drivers provided with the driver set. for example, blankcheck can be used to verify that a particular region is erased, and programverify can be used to verify that the data was programmed correctly. the method to use these other drivers is similar to the above mentioned drivers except that the gprs needs to be setup appropriately for that particular driver.
creating the flash programming tool AN4035 40/41 doc id 022669 rev 2 6.3 functional division of the external tool before creating the external tool for flash programming, thought should be given to how the software should be divided to meet the tool?s functional requirements. the following list gives an example of a simple functional division of the software: once tap controller enable, section 3.1: enabling the once tap controller . once register read, section 3.2: once register access . once register write, section 3.2: once register access . once status register read, section 3.4: once status register . debug mode during reset, section 3.5: entering debug mode during reset . single step, section 3.8: single step . exit from debug mode, section 3.9: exit from debug mode to normal execution . write gpr, section 3.10: gpr access . read gpr, section 3.10: gpr access . write spr, section 3.11: spr access . read spr, section 3.11: spr access . once memory read, section 3.12: once memory access . once memory write, section 3.12: once memory access . nexus3 single write, section 4.2: single memory write access . nexus3 burst write, section 4.3: burst block memory write access . nexus3 single read, section 4.4: single memory read access . nexus3 burst read, section 4.5: burst block memory read access . mmu initialization, section 5.2: setting up the memory management unit . internal sram initialization, section 5.1: internal sram initialization . s-record parser and loader. debug and driver initialization, section 6.2.1: debug and driver initialization . flash initialization, section 6.2.2: flashinit . flash block lock initialization, section 6.2.3: setlock . flash erase, section 6.2.4: flasherase . flash program, section 6.2.5: flashprogram .
AN4035 revision history doc id 022669 rev 2 41/41 7 revision history table 9. document revision history date revision changes 24-jan-2012 1 initial release. 18-sep-2013 2 updated disclaimer.
AN4035 doc id 022669 rev 2 41/41 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a particular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. st products are not designed or authorized for use in: (a) safety critical applications such as life supporting, active implanted devices or systems with product functional safety requirements; (b) aeronautic applications; (c) automotive applications or environments, and/or (d) aerospace applications or environments. where st products are not designed for such use, the purchaser shall use products at purchaser?s sole risk, even if st has been informed in writing of such usage, unless a product is expressly designated by st as being intended for ?automotive, automotive safety or medical? industry domains according to st product design specifications. products formally escc, qml or jan qualified are deemed suitable for use in aerospace by the corresponding governmental agency. resale of st products with provisions different from the statem ents and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or register ed trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2013 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - swed en - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN4035

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X